* Figure 8 : Mean outcome variables by village-year treatment status
* Sample used to study household outcomes
* Last Updated, Niriksha Shetty 03/31/206

clear
clear mata
clear matrix
set maxvar 20000
set more off

pwd
cap cd c(`pwd')

estimates clear

use "../dta/reduced-form-master.dta", clear

*Using balanced panel
keep if ex_post_balp==1

* Easier labelling for graphs
la var w_real_sav "savings (INR)"
la var w_real_lent "money lent out (INR)"
la var w_real_borrow "money borrowed (INR)"
la var w_real_cons "total consumption (INR)"
la var w_real_food_exp "food expenditure (INR)"
la var w_real_nonfood_exp "non-food expenditure (INR)"
la var w_real_durables_exp "durables expenditure (INR)"
la var w_real_events_exp "events expenditure (INR)"
la var w_real_gifts_out "gifts/transfers made (INR)"
la var w_real_income "annual income(INR)"
la var w_real_gifts_in "gifts/transfers received (INR)"
la var food_sufficiency_child "food sufficiency for children"
la var fladder_std "financial situation (sd units)"
la var outlook_std "good things happen (sd units)"
la var control_std "control over life (sd units)"

* by treatment groups
foreach var of varlist w_real_sav w_real_lent w_real_borrow w_real_cons w_real_food_exp w_real_nonfood_exp w_real_durables_exp w_real_events_exp w_real_gifts_out  w_real_income w_real_gifts_in food_sufficiency_child fladder_std outlook_std control_std {
bys mkt_year: egen avg_`var'_To=mean(`var') if originaltvillage==1 & surveyed 
bys mkt_year: egen avg_`var'_Tn=mean(`var') if firstt_2007 & surveyed 
bys mkt_year: egen avg_`var'_T9=mean(`var') if firstt_2009 & surveyed  
bys mkt_year: egen avg_`var'_C=mean(`var') if Tvillage==0 & surveyed

lab var avg_`var'_To "Treatment 1"
lab var avg_`var'_Tn "Treatment 2"
lab var avg_`var'_T9 "Treatment Expansion"
lab var avg_`var'_C "Control Group"  
}

foreach var in w_real_cons w_real_sav w_real_lent w_real_borrow w_real_food_exp w_real_nonfood_exp w_real_durables_exp w_real_events_exp w_real_income w_real_gifts_out w_real_gifts_in food_sufficiency_child {
local l`var':variable label `var'
twoway connected  avg_`var'_To avg_`var'_Tn avg_`var'_T9 avg_`var'_C mkt_year, title("`l`var''", size(vsmall)) ylabel(,angle (30)) xlabel(2005(2)2013) xtitle("") graphregion(color(white)) plotregion(icolor(white)) msymbol(T D O)
graph save avg_`var', replace
graph export "../output/graphs/avg_`var'.emf", replace
}

foreach var in fladder_std outlook_std control_std {
local l`var':variable label `var'
twoway connected  avg_`var'_To avg_`var'_Tn avg_`var'_T9 avg_`var'_C mkt_year, title("`l`var''", size(vsmall)) ylabel(-1 0 1,angle (30)) yscale(r(-1 1)) xlabel(2005(2)2013) xtitle("") graphregion(color(white)) plotregion(icolor(white)) msymbol(T D O)
graph save avg_`var', replace
graph export "../output/graphs/avg_`var'.emf", replace
}

*combining individual graphs
grc1leg avg_w_real_sav.gph avg_w_real_lent.gph avg_w_real_borrow.gph avg_w_real_cons.gph avg_w_real_food_exp.gph avg_w_real_nonfood_exp.gph avg_w_real_durables_exp.gph avg_w_real_events_exp.gph  avg_w_real_gifts_out.gph avg_w_real_income.gph avg_w_real_gifts_in.gph avg_food_sufficiency_child.gph avg_fladder_std.gph avg_outlook_std.gph avg_control_std.gph, graphregion(color(white) lwidth(large)) plotregion(icolor(white)) 
graph export "../output/graphs/f8.emf", replace


